package org.fuys.coder.infrastructure.repository;

import org.fuys.coder.common.entity.Pair;
import org.fuys.coder.domain.user.repository.IUserOperationRepository;
import org.fuys.coder.infrastructure.util.RedisUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @projectName: fuys-low-coder
 * @package: org.fuys.coder.infrastructure.repository
 * @className: UserOperationRepository
 * @author: WangJing
 * @description: 用户操作仓储
 * @date: 2024/9/6 20:23
 * @version: 1.0
 */
@Service
public class UserOperationRepository implements IUserOperationRepository {
    @Resource
    private RedisUtil redisUtil;

    @Override
    public void setNewFollowerCache(String redisKey, List<Pair<Integer, Integer>> userNoticed, int i, TimeUnit days) {
        redisUtil.setList(redisKey,userNoticed);
        redisUtil.expire(redisKey,i,days);
    }

    @Override
    public List<Object> getFollowerCache(String redisKey) {
        return redisUtil.getList(redisKey);
    }

    @Override
    public void addFollowerCache(String redisKey, Integer authorId) {
        redisUtil.addList(redisKey,authorId);
    }
}
